package ink.metoo.gude.module.security.repository

import ink.metoo.gude.module.security.domain.ddl.VerificationCode
import org.springframework.data.jpa.repository.Query
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation
import org.springframework.stereotype.Repository

@Repository
interface VerificationCodeRepository : JpaRepositoryImplementation<VerificationCode, Long> {

    @Query(
        """
        from VerificationCode 
        where key = :key
          and type = :type
        order by createDate desc
        limit 1
        """
    )
    fun findLastVerificationCode(key: String, type: String): VerificationCode?

}